﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace RoofusUIControls
{
    /// <summary>
    /// User control that will allow the user to specify how to hook up one input pin.
    /// </summary>
    public partial class InputPinSpecification : UserControl
    {
        public InputPinSpecification()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty PinNameProperty = DependencyProperty.Register(
            "PinName",
            typeof(string),
            typeof(InputPinSpecification),
            new PropertyMetadata(null, new PropertyChangedCallback(InputPinNameChanged)));

        /// <summary>
        /// Sets the name of the input pin. This is a label -- the user can't actually change this. :-)
        /// </summary>
        public string PinName
        {
            set { SetValue(PinNameProperty, value);}
            get { return (string) GetValue(PinNameProperty); }
        }

        /// <summary>
        /// Called when the property is changed. Update our display to reflect it...
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        static void InputPinNameChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            InputPinSpecification sp = source as InputPinSpecification;
            sp.InputPinName.Content = e.NewValue;
        }

        /// <summary>
        /// Dependency property that has all the incoming input connections. Whee!
        /// </summary>
        public static readonly DependencyProperty InputConnectionsProperty = DependencyProperty.Register(
            "InputConnections",
            typeof(List<SurfaceItemConnector>),
            typeof(InputPinSpecification));

        /// <summary>
        /// The incoming connections.
        /// </summary>
        public List<SurfaceItemConnector> InputConnections
        {
            set { SetValue(InputConnectionsProperty, value);}
            get { return (List<SurfaceItemConnector>)GetValue(InputConnectionsProperty); }
        }
    }
}
